package com.ruoyi.service.api.factory;

import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.service.api.RemoteServiceService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 文件服务降级处理
 * 
 * @author ruoyi
 */
@Component
public class RemoteServiceFallbackFactory implements FallbackFactory<RemoteServiceService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteServiceFallbackFactory.class);

    @Override
    public RemoteServiceService create(Throwable throwable)
    {
        log.error("服务项目调用失败:{}", throwable.getMessage());
        return new RemoteServiceService() {

            @Override
            public AjaxResult getInfo(Long id, String source) {
                return AjaxResult.error("通过id获取服务项目信息失败:" + throwable.getMessage());
            }

            @Override
            public AjaxResult getInfo(Long[] id, String source) {
                return AjaxResult.error("通过id列表获取服务项目信息失败:" + throwable.getMessage());
            }
        };
    }
}
